<!DOCTYPE html>
<html>
<head>
    <title>文件上传</title>
    <meta charset="utf-8">
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
</head>
<body>
    <form method="POST" enctype="multipart/form-data">
        <input type="file" name="file">
        <button type="button" id="upload">上传</button>
    </form>
    <div id="result"></div>
    <script>
        $(function() {
            $('#upload').on('click', function() {
                var formData = new FormData($('form')[0]);
                $.ajax({
                    url: 'prest/api/upload.php',
                    type: 'POST',
                    data: formData,
                    processData: false,
                    contentType: false,
                    success: function(data) {
                        $('#result').html(data);
                    }
                });
            });
        });
    </script>
</body>
</html>